-- 格式要UTF8-BOM
local TWaryLua = require "TWaryLua";
local json = require "json"
local all_info = require "lua.all_info"
local genpwd = require "lua.GenPassword"
local initData = require "1";



local google = {
  a = {
    google_pass = 'biAMrNcKiL',
    google_check = 'MJUUCTLSJZRUW2KM',
    google_xor = '000A006800000069000000410000004D000000720000004E000000630000004B000A00630000004C000000000000000000000000000000000000000000000000',
  },
  b = {
    google_pass = 'ZFAsufbJmy',
    google_check = 'LJDEC43VMZREU3LZ',
    google_xor = '000A00500000004600000041000000730000007500000066000000620000004A000A006700000079000000000000000000000000000000000000000000000000',
  },
  c = {
    google_pass = 'lzkgPVsPkm',
    google_check = 'NR5GWZ2QKZZVA23N',
    google_xor = '000A00660000007A0000006B0000006700000050000000560000007300000050000A00610000006D000000000000000000000000000000000000000000000000',
  },
  d = {
    google_pass = 'BCcGFZhsDt',
    google_check = 'IJBWGR2GLJUHGRDU',
    google_xor = '000A0048000000430000006300000047000000460000005A0000006800000073000A004E00000074000000000000000000000000000000000000000000000000',
  },
  e = {
    google_pass = 'TqBycqBquV',
    google_check = 'KRYUE6LDOFBHC5KW',
    google_xor = '000A005E00000071000000420000007900000063000000710000004200000071000A007F00000056000000000000000000000000000000000000000000000000',
  },
  f = {
    google_pass = 'BEiyctcYiO',
    google_check = 'IJCWS6LDORRVS2KP',
    google_xor = '000A004800000045000000690000007900000063000000740000006300000059000A00630000004F000000000000000000000000000000000000000000000000',
  },
  g = {
    google_pass = 'CspyzdgToi',
    google_check = 'INZXA6L2MRTVI33J',
    google_xor = '000A00490000007300000070000000790000007A000000640000006700000054000A006500000069000000000000000000000000000000000000000000000000',
  },
  h = {
    google_pass = 'LrdoJzklwB',
    google_check = 'JRZGI32KPJVWY52C',
    google_xor = '000A004600000072000000640000006F0000004A0000007A0000006B0000006C000A007D00000042000000000000000000000000000000000000000000000000',
  },
  i = {
    google_pass = 'ZPTAzJetdI',
    google_check = 'LJIFIQL2JJSXIZCJ',
    google_xor = '000A00500000005000000054000000410000007A0000004A0000006500000074000A006E00000049000000000000000000000000000000000000000000000000',
  },
  j = {
    google_pass = 'sNEuCpaJLM',
    google_check = 'ONHEK5KDOBQUUTCN',
    google_xor = '000A00790000004E00000045000000750000004300000070000000610000004A000A00460000004D000000000000000000000000000000000000000000000000',
  },
  k = {
    google_pass = 'ZMffDoCDAM',
    google_check = 'LJGWMZSEN5BUIQKN',
    google_xor = '000A00500000004D0000006600000066000000440000006F0000004300000044000A004B0000004D000000000000000000000000000000000000000000000000',
  },
  l = {
    google_pass = 'oueOhamksn',
    google_check = 'N52WKT3IMFWWW43O',
    google_xor = '000A006500000075000000650000004F00000068000000610000006D0000006B000A00790000006E000000000000000000000000000000000000000000000000',
  },
  m = {
    google_pass = 'MzMChbxTyl',
    google_check = 'JV5E2Q3IMJ4FI6LM',
    google_xor = '000A00470000007A0000004D0000004300000068000000620000007800000054000A00730000006C000000000000000000000000000000000000000000000000',
  },
  n = {
    google_pass = 'vJiIktvFIu',
    google_check = 'OZFGSSLLOR3EMSLV',
    google_xor = '000A007C0000004A00000069000000490000006B000000740000007600000046000A004300000075000000000000000000000000000000000000000000000000',
  },
  o = {
    google_pass = 'hGjSfTDEig',
    google_check = 'NBDWUU3GKRCEK2LH',
    google_xor = '000A0062000000470000006A0000005300000066000000540000004400000045000A006300000067000000000000000000000000000000000000000000000000',
  },
  p = {
    google_pass = 'QukxALMabm',
    google_check = 'KF2WW6CBJRGWCYTN',
    google_xor = '000A005B000000750000006B00000078000000410000004C0000004D00000061000A00680000006D000000000000000000000000000000000000000000000000',
  },
  q = {
    google_pass = 'RWIHsDwlLb',
    google_check = 'KJLUSSDTIR3WYTDC',
    google_xor = '000A00580000005700000049000000480000007300000044000000770000006C000A004600000062000000000000000000000000000000000000000000000000',
  },
  r = {
    google_pass = 'XxVEgiEFPB',
    google_check = 'LB4FMRLHNFCUMUCC',
    google_xor = '000A005200000078000000560000004500000067000000690000004500000046000A005A00000042000000000000000000000000000000000000000000000000',
  },
  s = {
    google_pass = 'GEqxGerHAe',
    google_check = 'I5CXC6CHMVZEQQLF',
    google_xor = '000A004D00000045000000710000007800000047000000650000007200000048000A004B00000065000000000000000000000000000000000000000000000000',
  },
  t = {
    google_pass = 'oOpHqnNdeW',
    google_check = 'N5HXASDRNZHGIZKX',
    google_xor = '000A00650000004F0000007000000048000000710000006E0000004E00000064000A006F00000057000000000000000000000000000000000000000000000000',
  },
  u = {
    google_pass = 'QQMYrvdPoc',
    google_check = 'KFIU2WLSOZSFA33D',
    google_xor = '000A005B000000510000004D0000005900000072000000760000006400000050000A006500000063000000000000000000000000000000000000000000000000',
  },
  v = {
    google_pass = 'UUGMHuxxlx',
    google_check = 'KVKUOTKIOV4HQ3DY',
    google_xor = '000A005F00000055000000470000004D00000048000000750000007800000078000A006600000078000000000000000000000000000000000000000000000000',
  },
  w = {
    google_pass = 'qdchhIIclR',
    google_check = 'OFSGG2DIJFEWG3CS',
    google_xor = '000A007B00000064000000630000006800000068000000490000004900000063000A006600000052000000000000000000000000000000000000000000000000',
  },
  x = {
    google_pass = 'vfjSOZDVPC',
    google_check = 'OZTGUU2PLJCFMUCD',
    google_xor = '000A007C000000660000006A000000530000004F0000005A0000004400000056000A005A00000043000000000000000000000000000000000000000000000000',
  },
  y = {
    google_pass = 'dPqDTNxyli',
    google_check = 'MRIHCRCUJZ4HS3DJ',
    google_xor = '000A006E000000500000007100000044000000540000004E0000007800000079000A006600000069000000000000000000000000000000000000000000000000',
  },
  z = {
    google_pass = 'FeFNfnRSrk',
    google_check = 'IZSUMTTGNZJFG4TL',
    google_xor = '000A004C00000065000000460000004E000000660000006E0000005200000053000A00780000006B000000000000000000000000000000000000000000000000',
  },
}


if google[initData.short] == nil then
    error("错误的错误的short缩写值")
    return
end







-- 在这里需要整合一份, 真正的配置文件
local content = "";
content = content .. '\nlocal all_info = {'
content = content .. '\n    name = "'.. initData.name ..'",       -- 棋牌的名称 '
content = content .. '\n    aliuser = "'.. initData.aliuser ..'",         -- 阿里云用户名 '
content = content .. '\n    alipass = "'.. initData.alipass ..'",           -- 阿里云密码 '
content = content .. '\n'
content = content .. '\n'
content = content .. '\n    sql_address_public     = "'.. all_info.sql_address_public ..'", -- SQL服务器地址(公) '
content = content .. '\n    sql_address_private    = "'.. all_info.sql_address_private ..'", -- SQL服务器地址(私) '
content = content .. '\n'
content = content .. '\n    web_address_public     = "'.. all_info.web_address_public ..'", -- web服务器地址(公) '
content = content .. '\n    web_address_private    = "'.. all_info.web_address_private ..'", -- web服务器地址(私) '
content = content .. '\n'
content = content .. '\n    game_address_public    = "'.. all_info.game_address_public ..'", -- game服务器地址(公) '
content = content .. '\n    game_address_private   = "'.. all_info.game_address_private ..'", -- game服务器地址(私) '
content = content .. '\n'
content = content .. '\n    proxy_address_public   = "'.. all_info.proxy_address_public ..'", -- proxy服务器地址(公) '
content = content .. '\n    proxy_address_private  = "'.. all_info.proxy_address_private ..'", -- proxy服务器地址(私) '
content = content .. '\n'
content = content .. '\n    java_address_public    = "'.. all_info.java_address_public ..'", -- java服务器地址(公) '
content = content .. '\n    java_address_private   = "'.. all_info.java_address_private ..'", -- java服务器地址(私) '
content = content .. '\n'
content = content .. '\n    javam_address_public   = "'.. all_info.javam_address_public ..'", -- javam服务器地址(公) '
content = content .. '\n    javam_address_private  = "'.. all_info.javam_address_private ..'", -- javam服务器地址(私) '
content = content .. '\n'
content = content .. '\n'
content = content .. '\n    -- ============================================================'
content = content .. '\n    -- 数据库相关的内容'
content = content .. '\n    sql_port = "1433",'
content = content .. '\n'
content = content .. '\n'
content = content .. '\n    server_pass     = "'.. genpwd.server_pass     ..'", -- 服务器密码 '
content = content .. '\n    sa_pass         = "'.. genpwd.sa_pass         ..'", -- SA 数据库密码'
content = content .. '\n    cpp_pass        = "'.. genpwd.cpp_pass        ..'", -- cpp 数据库密码'
content = content .. '\n    iis_pass        = "'.. genpwd.iis_pass        ..'", -- IIS 数据库密码'
content = content .. '\n    java_pass       = "'.. genpwd.java_pass       ..'", -- java 数据库密码'
content = content .. '\n    node_login_pass = "'.. genpwd.node_login_pass ..'", -- node 登录数据库密码'
content = content .. '\n    node_pay_pass   = "'.. genpwd.node_pay_pass   ..'", -- node 支付数据库密码'
content = content .. '\n    google_pass     = "'.. google[initData.short].google_pass     ..'", -- google 验证码'
content = content .. '\n    google_check    = "'.. google[initData.short].google_check    ..'", -- google 验证码'
content = content .. '\n'
content = content .. '\n'
content = content .. '\n'
content = content .. '\n    -- oss 桶相关内容'
content = content .. '\n    oss_accesskey_id      = "'.. initData.oss_accesskey_id ..'",'
content = content .. '\n    oss_accesskey_secret  = "'.. initData.oss_accesskey_secret ..'",'
content = content .. '\n    xxxx                  = "'.. initData.xxxx ..'",  -- https://xxxxdownload.oss-cn-shenzhen.aliyuncs.com/ '
content = content .. '\n'
content = content .. '\n    ecs_accesskey_id      = "'.. initData.ecs_accesskey_id ..'",'
content = content .. '\n    ecs_accesskey_secret  = "'.. initData.ecs_accesskey_secret ..'",'
content = content .. '\n    downurl               = "http://'  .. initData.xxxx .. 'download.oss-cn-shenzhen.aliyuncs.com/Download",'
content = content .. '\n    myaddress             = "https://' .. initData.xxxx .. 'download.oss-cn-shenzhen.aliyuncs.com/myaddress.json",'
content = content .. '\n'
content = content .. '\n'
content = content .. '\n    game_server_guid   = "'.. all_info.game_server_guid ..'", -- 游戏服机器标识 '
content = content .. '\n}'
content = content .. '\n'
content = content .. '\n'
content = content .. '\n'
content = content .. '\n'
content = content .. '\nreturn all_info'


print(content)

TWaryLua.SaveToFile("./allinfo/all_info.lua", content)
TWaryLua.SaveToFile("./record/".. initData.name .. ".lua", content)


local content = initData.name;
content = content .. "\n" .. "阿里云：";
content = content .. "\n" .. initData.aliuser;
content = content .. "\n" .. initData.alipass;
content = content .. "\n";
content = content .. "\n" .. "OSS:";
content = content .. "\n" .. initData.oss_accesskey_id;
content = content .. "\n" .. initData.oss_accesskey_secret;
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "服务器密码： " .. genpwd.server_pass;
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "sa                " .. genpwd.sa_pass;
content = content .. "\n" .. "cpp_app           " .. genpwd.cpp_pass;
content = content .. "\n" .. "iis_app           " .. genpwd.iis_pass;
content = content .. "\n" .. "java_app          " .. genpwd.java_pass;
content = content .. "\n" .. "node_login_app    " .. genpwd.node_login_pass;
content = content .. "\n" .. "node_pay_app      " .. genpwd.node_pay_pass;
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "跳板机：";
content = content .. "\n" .. all_info.proxy_address_public .. "(公)";
content = content .. "\n" .. all_info.proxy_address_private .."(私有)";
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "java：";
content = content .. "\n" .. all_info.java_address_public ..  "(公)";
content = content .. "\n" .. all_info.java_address_private .."(私有)";
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "java-后台管理：";
content = content .. "\n" .. all_info.javam_address_public .. "(公)";
content = content .. "\n" .. all_info.javam_address_private .."(私有)";
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "sql：";
content = content .. "\n" .. all_info.sql_address_public ..  "(公)";
content = content .. "\n" .. all_info.sql_address_private .."(私有)";
content = content .. "\n" .. "远程连接端口：3880";
content = content .. "\n";
content = content .. "\n" .. "web：";
content = content .. "\n" .. all_info.web_address_public ..  "(公)";
content = content .. "\n" .. all_info.web_address_private .."(私有)";
content = content .. "\n" .. "远程连接端口：3880";
content = content .. "\n";
content = content .. "\n" .. "game：";
content = content .. "\n" .. all_info.game_address_public ..  "(公)";
content = content .. "\n" .. all_info.game_address_private .."(私有)";
content = content .. "\n" .. "远程连接端口：3880";
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "谷歌验证码：[" .. initData.short .. "]";
content = content .. "\n" .. google[initData.short].google_pass;
content = content .. "\n" .. google[initData.short].google_check ;
content = content .. "\n";
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "域名：问阿源";
content = content .. "\n";
content = content .. "\n";
content = content .. "\n" .. "https://" .. initData.xxxx .. "download.oss-cn-shenzhen.aliyuncs.com/myaddress.json"
content = content .. "\n\n\n";


content = content .. "\n" .. initData.name .. "\n谷歌验证码是:"
content = content .. "\n" .. google[initData.short].google_pass;
content = content .. "\n" .. google[initData.short].google_check ;
content = content .. "\n\n\n" 

content = content .. "\n" .. initData.name .. "域名绑定:"
content = content .. "\n" .. all_info.proxy_address_public

TWaryLua.SaveToFile("./record/".. initData.name..".txt",  content)



-- 上报数据库相关
local postData = {
	name = initData.name,
	userid = "sa",
	ip_public = all_info.sql_address_public,
	password = genpwd.sa_pass,
	sql_port = 1433,
}
local c =json.encode(postData)
print(c)
local a, b = TWaryLua.Post("http://180.150.135.195:52893/api/sqlinfo/add",json.encode(postData))

print(a, b)

